<?php

require_once( 'Classes/Xml/XmlElement.php' );

class XmlDatabaseKeyElement extends XmlElement {
	
	function XmlDatabaseKeyElement( &$oConfiguration, &$oKey, $sShowKeyConfigOption, $sKeyType, $sGetTableFunction ) {

		$this->XmlElement( $sKeyType );
		$this->AddAttribute( 'NAME', $oKey->GetName() );
		$this->AddAttribute( 'ID'  , $oKey->GetName() );
		
		if ( $oConfiguration->GetProperty( $sShowKeyConfigOption ) ) {
			foreach( $oKey->GetColumnNames() as $iSequence => $sThisColumn ) {
				$oKeyColumn = new XmlElement( $sKeyType . '_COLUMN' );
				$oKeyColumn->AddAttribute( 'COLUMN_ID'   , $oKey->$sGetTableFunction() . '.' . $sThisColumn );
				$oKeyColumn->AddAttribute( 'COLUMN_NAME' , $sThisColumn );
				$oKeyColumn->AddAttribute( 'SEQUENCE'    , $iSequence );
				$this->AddElement( $oKeyColumn );
			}
		}
	}
}
	
?>
